home *** CD-ROM | disk | FTP | other *** search
- Path: news.sprintlink.net!datalytics!usenet
- From: Rob Stewart <stew@datalytics.com>
- Newsgroups: comp.lang.c++,comp.object,comp.object.logic
- Subject: Re: polymorphism
- Date: Fri, 22 Mar 1996 13:43:23 -0500
- Organization: Datalytics, Inc
- Message-ID: <3152F4CB.2745@datalytics.com>
- References: <31513CBB.41C6@mi.leeds.ac.uk> <4irhd8$g1i@mo6.rc.tudelft.nl>
- NNTP-Posting-Host: 204.62.224.71
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (WinNT; I)
-
- Ejo Schrama wrote:
- >
- > aniko@mi.leeds.ac.uk (Aniko Simon) wrote:
- > >Hi;
- > >
- > >Can anyone help:
- > >what does the term "polymorphism" mean in OO programming ?
- > >
- >
- > Yes, it means that a function, designed to work on a particular type
- > of object (or objects) also works for inhereted objects. For example:
- >
- > change(world);
- >
- > where change is a function designed to work with world objects can
- > also be used for venus objects:
- >
- > change(venus);
- >
- > where venus is inhereted from the base object world.
- >
-
- More accurately, it means that derived classes can (re)implement
- a (pure) virtual base class function, and the correct derived
- class function will be invoked based upon the type of the object
- being pointed to (or referenced) rather than on the type of the
- pointer (reference).
-
- If that wasn't clear enough, let me elaborate. If you have a
- pointer to a base class, but assign it the address of a derived
- class object, ordinarily, calling a function through that
- pointer would invoke a base class function. However, with
- virtual functions, the derived class' function would be invoked
- since the pointer actually points to a derived class object.
-
- --
- Robert Stewart | My opinions are usually my own.
- Datalytics, Inc. | stew@datalytics.com
-